package com.jeeplus.test.jlnu.archivalBatch.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.test.jlnu.archivalBatch.domain.JlnuArchivalBatch;
import com.jeeplus.test.jlnu.archivalBatch.service.JlnuArchivalBatchService;
import com.jeeplus.test.jlnu.archivalInfo.domain.vo.ArchivalInfoReqVo;
import com.jeeplus.test.tools.resp.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/jlnuArchivalBatch")
public class JlnuArchivalBatchController {

    @Autowired
    private JlnuArchivalBatchService jlnuArchivalBatchService;

    @ApiOperation("档案信息分页查询")
    @GetMapping("/page")
    public Page<JlnuArchivalBatch> getArchivalInfoPage(JlnuArchivalBatch archivalInfoReqVo, @RequestParam(defaultValue = "1") int pageNum,
                                                       @RequestParam(defaultValue = "10") int pageSize) {
        Page<JlnuArchivalBatch> page = new Page<>(pageNum, pageSize);
        Page<JlnuArchivalBatch> pageResult = jlnuArchivalBatchService.getArchivalBatchPage(archivalInfoReqVo, page);
        return pageResult;
    }

    @PostMapping("/insert")
    public int insert(@RequestBody JlnuArchivalBatch jlnuArchivalBatch) {
        return jlnuArchivalBatchService.insert(jlnuArchivalBatch);
    }

    @DeleteMapping("/delete/{id}")
    public int deleteById(@PathVariable Integer id) {
        return jlnuArchivalBatchService.deleteById(id);
    }

    @PutMapping("/update")
    public int update(@RequestBody JlnuArchivalBatch jlnuArchivalBatch) {
        return jlnuArchivalBatchService.update(jlnuArchivalBatch);
    }

    @GetMapping("/select/{id}")
    public JlnuArchivalBatch selectById(@PathVariable Integer id) {
        return jlnuArchivalBatchService.selectById(id);
    }

    @GetMapping("/selectAll")
    public List<JlnuArchivalBatch> selectAll() {
        return jlnuArchivalBatchService.selectAll();
    }


    /*批量提交审批接口接口*/
    @PostMapping("/approval")
    public R approval(@RequestBody List<JlnuArchivalBatch> jlnuArchivalBatch) {
        jlnuArchivalBatchService.approval(jlnuArchivalBatch);
        return R.suc();
    }

}
